<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of fernsClfTrain</title>
  <meta name="keywords" content="fernsClfTrain">
  <meta name="description" content="Train random fern classifier.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html classify -->
<h1>fernsClfTrain
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Train random fern classifier.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [ferns,hsPr] = fernsClfTrain( data, hs, varargin ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Train random fern classifier.

 See &quot;Fast Keypoint Recognition in Ten Lines of Code&quot; by Mustafa Ozuysal,
 Pascal Fua and Vincent Lepetit, CVPR07.

 Dimensions:
  M - number ferns
  S - fern depth
  F - number features
  N - number input vectors
  H - number classes

 USAGE
  [ferns,hsPr] = fernsClfTrain( data, hs, [varargin] )

 INPUTS
  data     - [NxF] N length F feature vectors
  hs       - [Nx1] target output labels in [1,H]
  varargin - additional params (struct or name/value pairs)
   .S        - [10] fern depth (ferns are exponential in S)
   .M        - [50] number of ferns to train
   .thrr     - [0 1] range for randomly generated thresholds
   .bayes    - [1] if true combine probs using bayes assumption
   .ferns    - [] if given reuse previous ferns (recompute pFern)

 OUTPUTS
  ferns    - learned fern model w the following fields
   .fids     - [MxS] feature ids for each fern for each depth
   .thrs     - [MxS] threshold corresponding to each fid
   .pFern    - [2^SxHxM] learned log probs at fern leaves
   .bayes    - if true combine probs using bayes assumption
   .inds     - [NxM] cached indices for original training data
   .H        - number classes
  hsPr     - [Nx1] predicted output labels

 EXAMPLE
  N=5000; H=5; d=2; [xs0,hs0,xs1,hs1]=demoGenData(N,N,H,d,1,1);
  fernPrm=struct('S',4,'M',50,'thrr',[-1 1],'bayes',1);
  tic, [ferns,hsPr0]=fernsClfTrain(xs0,hs0,fernPrm); toc
  tic, hsPr1 = fernsClfApply( xs1, ferns ); toc
  e0=mean(hsPr0~=hs0); e1=mean(hsPr1~=hs1);
  fprintf('errors trn=%f tst=%f\n',e0,e1); figure(1);
  subplot(2,2,1); visualizeData(xs0,2,hs0);
  subplot(2,2,2); visualizeData(xs0,2,hsPr0);
  subplot(2,2,3); visualizeData(xs1,2,hs1);
  subplot(2,2,4); visualizeData(xs1,2,hsPr1);

 See also <a href="fernsClfApply.html" class="code" title="function [hs,probs] = fernsClfApply( data, ferns, inds )">fernsClfApply</a>, <a href="fernsInds.html" class="code" title="function inds = fernsInds( data, fids, thrs )">fernsInds</a>

 Piotr's Computer Vision Matlab Toolbox      Version 2.61
 Copyright 2014 Piotr Dollar.  [pdollar-at-gmail.com]
 Licensed under the Simplified BSD License [see external/bsd.txt]</pre></div>





<!-- Start of Google Analytics Code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4884268-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!-- end of Google Analytics Code -->

<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>
